#ifndef WINDOW_DELEGATE_H
#define WINDOW_DELEGATE_H

#include "capi/views/cef_window_delegate_capi.h"
#include "capi/views/cef_browser_view_capi.h"
#include "capi/views/cef_window_capi.h"

#include "window.h"
#include "logger.h"

typedef struct _window_delegate
{
    cef_window_delegate_t cef_window_delegate;
    cef_browser_view_t *browser_view;
    int width;
    int height;
    char *icon_png_path;
    char *title;
    int is_frameless;
    int is_devtools;
} window_delegate;

void CEF_CALLBACK on_window_created(struct _cef_window_delegate_t *self, struct _cef_window_t *window);

void CEF_CALLBACK on_window_closing(struct _cef_window_delegate_t *self, struct _cef_window_t *window);

void CEF_CALLBACK on_window_destroyed(struct _cef_window_delegate_t *self, struct _cef_window_t *window);

void CEF_CALLBACK on_window_activation_changed(struct _cef_window_delegate_t *self, struct _cef_window_t *window, int active);

void CEF_CALLBACK on_window_bounds_changed(struct _cef_window_delegate_t *self, struct _cef_window_t *window, const cef_rect_t *new_bounds);

void CEF_CALLBACK on_window_fullscreen_transition(struct _cef_window_delegate_t *self, struct _cef_window_t *window, int is_completed);

cef_rect_t CEF_CALLBACK get_initial_bounds(struct _cef_window_delegate_t *self, struct _cef_window_t *window);

struct _cef_window_t *CEF_CALLBACK get_parent_window(struct _cef_window_delegate_t *self, struct _cef_window_t *window, int *is_menu, int *can_activate_menu);

int CEF_CALLBACK is_window_modal_dialog(struct _cef_window_delegate_t *self, struct _cef_window_t *window);

cef_show_state_t CEF_CALLBACK get_initial_show_state(struct _cef_window_delegate_t *self, struct _cef_window_t *window);

int CEF_CALLBACK is_frameless(struct _cef_window_delegate_t *self, struct _cef_window_t *window);

int CEF_CALLBACK with_standard_window_buttons(struct _cef_window_delegate_t *self, struct _cef_window_t *window);

int CEF_CALLBACK get_titlebar_height(struct _cef_window_delegate_t *self, struct _cef_window_t *window, float *titlebar_height);

cef_state_t CEF_CALLBACK accepts_first_mouse(struct _cef_window_delegate_t *self, struct _cef_window_t *window);

int CEF_CALLBACK can_resize(struct _cef_window_delegate_t *self, struct _cef_window_t *window);

int CEF_CALLBACK can_maximize(struct _cef_window_delegate_t *self, struct _cef_window_t *window);

int CEF_CALLBACK can_minimize(struct _cef_window_delegate_t *self, struct _cef_window_t *window);

int CEF_CALLBACK can_close(struct _cef_window_delegate_t *self, struct _cef_window_t *window);

int CEF_CALLBACK on_accelerator(struct _cef_window_delegate_t *self, struct _cef_window_t *window, int command_id);

int CEF_CALLBACK on_key_event(struct _cef_window_delegate_t *self, struct _cef_window_t *window, const cef_key_event_t *event);

void CEF_CALLBACK on_theme_colors_changed(struct _cef_window_delegate_t *self, struct _cef_window_t *window, int chrome_theme);

cef_runtime_style_t CEF_CALLBACK get_window_runtime_style(struct _cef_window_delegate_t *self);

int CEF_CALLBACK get_linux_window_properties(struct _cef_window_delegate_t *self, struct _cef_window_t *window, struct _cef_linux_window_properties_t *properties);

//  cef_panel_delegate_t base;--------------------------------------
cef_size_t CEF_CALLBACK get_preferred_size(struct _cef_view_delegate_t *self, struct _cef_view_t *view);

cef_size_t CEF_CALLBACK get_minimum_size(struct _cef_view_delegate_t *self, struct _cef_view_t *view);

cef_size_t CEF_CALLBACK get_maximum_size(struct _cef_view_delegate_t *self, struct _cef_view_t *view);

int CEF_CALLBACK get_height_for_width(struct _cef_view_delegate_t *self, struct _cef_view_t *view, int width);

void CEF_CALLBACK on_parent_view_changed(struct _cef_view_delegate_t *self, struct _cef_view_t *view, int added, struct _cef_view_t *parent);

void CEF_CALLBACK on_child_view_changed(struct _cef_view_delegate_t *self, struct _cef_view_t *view, int added, struct _cef_view_t *child);

void CEF_CALLBACK on_window_changed(struct _cef_view_delegate_t *self, struct _cef_view_t *view, int added);

void CEF_CALLBACK on_layout_changed(struct _cef_view_delegate_t *self, struct _cef_view_t *view, const cef_rect_t *new_bounds);

void CEF_CALLBACK on_focus(struct _cef_view_delegate_t *self, struct _cef_view_t *view);

void CEF_CALLBACK on_blur(struct _cef_view_delegate_t *self, struct _cef_view_t *view);

void CEF_CALLBACK on_theme_changed(struct _cef_view_delegate_t *self, struct _cef_view_t *view);

// 初始化 window_delegate_t
window_delegate *_create_window_delegate(cef_browser_view_t *browser_view, int width, int heigth, char *icon_png_path, char *title, int isFrameless, int is_devtools);

#endif